<template>
  <div id="Auth">
    <p>授权获取中，请耐心等待。</p>
    <p>该应用只有中国石油大学（华东）的认证用户可使用</p>
  </div>
</template>

<script>
  import API from '../config/request';
  import {encodeData} from '../config/base64';
  export default {
    data(){
      return{
          url: API.URL,
          yibanAuth : API.Auth
      }

    },
    mounted() {
      this.getToken();
    },
    methods: {
      getToken() {
        let self = this
        this.$http.post(this.yibanAuth,
          {
            vq: this.$route.query.verify_request
          },
          {emulateJSON: true}
        ).then(
            (response) => {
              if (response.body != null ) {
                  if( 'studentNo' == 'undefined' || undefined ){
                    alert("请核实您的信息");
                  }
                  console.log(response)
                  let yb_studentid = encodeData(response.body.yb_studentid)
                  let classId = encodeData(response.body.classId)
                  let identity = encodeData(response.body.identity)

                  localStorage.setItem('studentNo', yb_studentid)
                  localStorage.setItem('classId', classId)
                  localStorage.setItem('identity', identity)

                  // if(response.body.identity == 0){
                  //   self.$router.push({path: '/counselor'})
                  // }else if(response.body.identity == 1){
                  //   self.$router.push({path: '/headerteacherIndex'})
                  // }else{
                  //   self.$router.push({path: '/grade/'+response.body.yb_studentid
                  //   })
                  // }
                }else{
                  alert("授权未成功")
                }
          },(response)=>{
              alert("访问服务器出错")
          })
      }
    }
  }
</script>

<style>

</style>
